package artid.com.arttogoa.parser;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * 
 * 
 * 类名称 ：ClasslistParse 类描述 ：4.20.商品分类/年代分类列表/快递公司列表 创建人 ：xiongbin 创建时间：2016-6-23
 * 上午10:59:36
 * 
 */
public class ClasslistParse extends AppItem implements Serializable {
	private static final long serialVersionUID = 1L;
	private List<Classlist> class_list = new ArrayList<ClasslistParse.Classlist>();
	private List<Classlist> age_list = new ArrayList<ClasslistParse.Classlist>();
	private List<Classlist> express_list = new ArrayList<ClasslistParse.Classlist>();
	private List<Classlist> bank_list = new ArrayList<ClasslistParse.Classlist>();

	@Override
	public void parse(JSONObject obj) {
		// TODO Auto-generated method stub
		if (null == obj) {
			return;
		}
		Classlist cl;
		JSONArray classArr = obj.optJSONArray("class_list");
		for (int i = 0; i < classArr.length(); i++) {
			cl = new Classlist();
			try {
				cl.setId(classArr.optJSONObject(i).getString("id"));
				cl.setName(classArr.optJSONObject(i).getString("name"));
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			class_list.add(cl);
		}
		JSONArray ageArr = obj.optJSONArray("age_list");
		for (int i = 0; i < ageArr.length(); i++) {
			cl = new Classlist();
			try {
				cl.setId(ageArr.optJSONObject(i).getString("id"));
				cl.setName(ageArr.optJSONObject(i).getString("name"));
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} 
			age_list.add(cl);
		}
		JSONArray expressArr = obj.optJSONArray("express_list");
		for (int i = 0; i < expressArr.length(); i++) {
			cl = new Classlist();
			try {
				cl.setId(expressArr.optJSONObject(i).getString("id"));
				cl.setName(expressArr.optJSONObject(i).getString("name"));
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			express_list.add(cl);
		}
		JSONArray bankArr = obj.optJSONArray("bank_list");
		for (int i = 0; i < bankArr.length(); i++) {
			cl = new Classlist();
			try {
				cl.setId(bankArr.optJSONObject(i).getString("id"));
				cl.setName(bankArr.optJSONObject(i).getString("name"));
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			bank_list.add(cl);
		}

	}

	public List<Classlist> getClass_list() {
		return class_list;
	}

	public void setClass_list(List<Classlist> class_list) {
		this.class_list = class_list;
	}

	public List<Classlist> getAge_list() {
		return age_list;
	}

	public void setAge_list(List<Classlist> age_list) {
		this.age_list = age_list;
	}

	public List<Classlist> getExpress_list() {
		return express_list;
	}

	public void setExpress_list(List<Classlist> express_list) {
		this.express_list = express_list;
	}
	
	public List<Classlist> getBank_list() {
		return bank_list;
	}

	public void setBank_list(List<Classlist> bank_list) {
		this.bank_list = bank_list;
	}

	@Override
	public String toString() {
		return "ClasslistParse [class_list=" + class_list + ", age_list="
				+ age_list + ", express_list=" + express_list + ", bank_list="
				+ bank_list + "]";
	}

	public class Classlist implements Serializable {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		private String name;
		private String id;

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public String getId() {
			return id;
		}

		public void setId(String id) {
			this.id = id;
		}

		@Override
		public String toString() {
			return "Classlist [name=" + name + ", id=" + id + "]";
		}

	}

}
